<template>
  <a-tree
    v-model:selectedKeys="selectedKeys"
    v-model:checkedKeys="checkedKeys"
    :default-expand-all="defaultExpandAll"
    checkable 
    :tree-data="dig()"
    show-icon
  >
    <template #icon="{ key,   }">
      <template  v-if="key != '0'">
       <img :src="m28"  alt="" srcset="" class="module-w-9">
       <!-- <img :src="m29" alt="" v-else srcset="" class="module-w-9"> -->
 
      </template>
    </template>

    <template #title="{ title, key }">
      <span v-if="key === '0-0-1-0'" style="color: #1890ff">{{ title }}</span>
      <template v-else>{{ title }}</template>
    </template>
  </a-tree>
</template>
<script lang="ts" setup>
import type { TreeProps } from 'ant-design-vue';
import { ref, watch ,toRefs} from 'vue';
import m28 from "../../assets/img/m28.png" 
import m29 from "../../assets/img/m29.png"
const props=defineProps({
  defaultExpandAll: {
    type: Boolean,
    default: false,
  },
})
const {defaultExpandAll}=toRefs(props); 
function dig(path = '0', level = 3) {
  const list: TreeProps['treeData'] = [];
  for (let i = 0; i < 1; i += 1) {
    const key = `${path}-${i}`;
    const treeNode: TreeProps['treeData'][number] = {
      title: key,
      key,
    };

    if (level > 0) {
      treeNode.children = dig(key, level - 1);
    }

    list.push(treeNode);
  }
  return list;
}

const selectedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const checkedKeys = ref<string[]>(['0-0-0', '0-0-1']);
watch(selectedKeys, () => {
  console.log('selectedKeys', selectedKeys);
});
watch(checkedKeys, () => {
  console.log('checkedKeys', checkedKeys);
});
</script>
<style lang="scss" scope>
.module-w-9{
  width: 14px;
  height: 14px;
  margin-left: -10px;
}
  
</style>



 